﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using MockPrjTeam2.DAO;

namespace MockPrjTeam2.Pages.Forms
{
    public partial class Login : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            _txtUserName.Focus();
            if (Session["username"] != null)
            {
                Response.Redirect("~/Home.aspx");
            }
        }

        protected void BtnLoginClick(object sender, EventArgs e)
        {
            var username = _txtUserName.Text;
            var password = _txtPassword.Text;
            var userBus = new Biz.SDManager();
            if (userBus.IsValidLogin(username, password))
            {
                Session.Contents["username"] = _txtUserName.Text;
                Session.Timeout = 60;
                Response.Redirect("~/Home.aspx");
            }
            else
            {
                _lblStatusLogin.Text = "Username or Password invalid !!!";
            }
            

        }
    }
}